package com.server.jaxrs;

import java.util.List;

import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.MatrixParam;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriInfo;

import com.server.ejb.ItemBean;
import com.server.entity.Item;

@Stateless
@Path("item")
public class ItemApi {

	@EJB
	private ItemBean ib;
	
    @Context
    private UriInfo context;

    /**
     * Default constructor. 
     */
    public ItemApi() {
        // TODO Auto-generated constructor stub
    }

    /**
     * Retrieves representation of an instance of ItemApi
     * @return an instance of String
     */
    @GET
    @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_ATOM_XML})
    @Path("{id}")
    public Item getItem(@PathParam("id") String itemId) {
        // TODO return proper representation object
        return ib.getItem(itemId);
    }
    
    @GET
    @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_ATOM_XML})
    @Path("{start}.{end}")
    public List<Item> getItem(@DefaultValue("10") @MatrixParam("size") int pagesize,@PathParam("strat") int start,@PathParam("end") int end) {
        // TODO return proper representation object
        return ib.getItemList(pagesize,start,end);
    }

    /**
     * PUT method for updating or creating an instance of ItemApi
     * @param content representation for the resource
     * @return an HTTP response with content of the updated or created resource.
     */
    @PUT
    @Consumes(MediaType.APPLICATION_JSON)
    public void putXml(String content) {
    	
    }

}